<template>
  <view class="container">
	 <image class="logo" src="../../static/logo.png"></image>
    <view class="form">
      <input v-model="username" placeholder="用户名"  style="margin-top: 30px;"/>
      <input v-model="password" type="password" placeholder="密码" style="margin-top: 15px;"/>
      <button @click="login">登录</button>
      <text @click="goToRegister" style="margin-top:15px;">还没有账号？点击<text style="color: red;">注册</text></text>
    </view>
  </view>
</template>

<script >
	import {userBar,driverBar} from '@/utils/tabBar.js'
	export default {  
	  data() {  
	    return {  
	      username: '', // 初始化 username  
	      password: ''  // 初始化 password  
	    };  
	  },
	  methods: {  
	    login() {  
			
			// 登录逻辑 测试底部导航栏 动态
			 if(this.username=="111"){
						   this.$store.dispatch('changeTabbar',userBar)
						   uni.switchTab({
						   	url:'/pages/index/personal'
						   })
			 }else{
						   this.$store.dispatch('changeTabbar',driverBar)
						   uni.switchTab({
						   	url:'/pages/driver/driver_center'
						   })
			 }
	   //    // 登录逻辑  
		  // if(this.username!=''&&this.password!=''){
			 //  // uni.request({
				//   this.$axios("/user/login",{
				// 	  params:{
				// 		  username:this.username,
				// 		  password:this.password
				// 	  }
				//   })
				//   .then(Response=>{
				// 	  console.log("进来了")
				// 	  console.log(Response)
				// 	   console.log("Response.data.token",Response.data.token)
				// 	  if(Response.statusCode==200){
						  
				// 	  	console.log("成功，我要跳转")
				// 			uni.setStorageSync("token",Response.data.token)
				// 			uni.setStorageSync("user",Response.data.user)
							
				// 	  		this.username='';
				// 	  		this.password='';
				// 	  		uni.switchTab({  
				// 	  			url: '/pages/index/personal' 
				// 	  		}) 
						
				// 		}else{
				// 			uni.showToast({
				// 				title:"账号密码错误，请重新填写",
				// 				icon:"none"
				// 			})
				// 			this.username='';
				// 			this.password='';
				// 		}
				//   })
		  // }else{
			 //  uni.showToast({
			 //  	title:"请输入完整",
			 //  	icon:"none"
			 //  })
		  // }
	      
	    },  
	    goToRegister() {  
	     uni.navigateTo({
	     	url:'/pages/index/register'
	     })
	    }  
	  }  
	}  
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background-color: #f5f5f5;
  height: 90vh;
}

.logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  margin-top: 50px;
  margin-bottom: 30px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.form {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  width: 300px;
}

input {
  width: 100%;
  height: 40px;
  margin-bottom: 15px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 10px;
  box-sizing: border-box;
}

button {
  width: 100%;
  height: 40px;
  background-color: #007aff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 10px;
}

button:hover {
  background-color: #005bb5;
}

.register-link {
  margin-top: 15px;
  color: #007aff;
  cursor: pointer;
}

.register-link:hover {
  text-decoration: underline;
}
</style>